# -*- coding:utf-8 -*-
from pynput import keyboard


def press_key(key):
    try:
        print('字母，数字 key {0} pressed'.format(key.char))
    except AttributeError:
        print('特殊键位 key {0} pressed'.format(key))


def release_key(key):
    '松开按键时执行。'
    print('{0} released'.format(key))
    if key == keyboard.Key.esc:
        raise keyboard.Listener.StopException("停止")


